package com.ddzh.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ddzh.pojo.Setmeal;
import com.ddzh.vo.SetmealVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface SetmealMapper extends BaseMapper<Setmeal> {
    @Select("select * from setmeal_t where id=#{id}")
    SetmealVo getInfo(Long id);

    @Select("select st.*\n" +
            "         from check_item_t i\n" +
            "         left join check_group_item_t cgit  on cgit.item_id=i.id\n" +
            "         left join setmeal_group_t sgt on cgit.group_id=sgt.group_id\n" +
            "         left join setmeal_t st on sgt.setmeal_id=st.id\n" +
            "         where i.id=#{itemId};")
    Setmeal findByItemId(@Param("itemId") Long itemId);

    @Select("select st.*\n" +
            "from setmeal_group_t sgt left join setmeal_t st on sgt.setmeal_id=st.id\n" +
            "where sgt.id=#{groupId}")
    Setmeal findByGroupId(@Param("groupId") Long groupId);

    @Select("select * from setmeal_t where name=#{name} and is_delete=0")
    Setmeal findByName(@Param("name") String name);

    @Select("select * from setmeal_t where name=#{code} and is_delete=0")
    Setmeal findByCode(@Param("code") String code);
}
